<?php
  namespace Home\Model;
  use Think\Model;
  class UserLogModel extends Model{
	  protected $userLog;
	  public function getUserLog($userId){
		  $this->userLog=$this->field("login_ip,login_time")->where("user_id=%d",$userId)->find();
		  return $this->userLog;
	  }
	  
	  public function setUserLog($userId,$login_ip,$login_time){
		  $data=array();
		  $data['login_ip']=$login_ip;
		  $data['user_id']=$userId;
		  $data['login_time']=$login_time;
		  ;
		  if(empty($this->userLog)){
			  $this->field('user_id,login_ip,login_time')->data($data)->add();
			  return true;
		  }
		  $this->field('login_ip,login_time')->where("user_id=%d",$userId)->data($data)->save();
	  }
  }